package com.szgr.baoyin.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.szgr.baoyin.R;
import com.szgr.baoyin.utils.MyTool;
import com.szgr.baoyin.utils.SystemBarTintManager;

public class BigPictureActivity extends Activity implements View.OnClickListener {

    private SystemBarTintManager mTintManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_big_picture);

        findViewById(R.id.action_bar_left).setOnClickListener(this);
        ImageView img_bigPic = (ImageView) findViewById(R.id.big_pic_image_view);
        Intent intent = getIntent();
        if(intent != null && intent.hasExtra("url")){
            String url = intent.getStringExtra("url");
            MyTool.showPicture(this,img_bigPic,url);
        }

        //判断操作系统的版本
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // 状态栏透明 需要在创建SystemBarTintManager之前调用。
            setTranslucentStatus(true);//方法如下
        }
        mTintManager = new SystemBarTintManager(this);
        // 设置状态栏背景
        mTintManager.setStatusBarTintEnabled(true);
        mTintManager.setStatusBarTintResource(R.color.main_blue);//颜色可以随便修改

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.action_bar_left:
                finish();
                break;
        }
    }

    protected void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
}
